package com.main.hotel.repository;

import com.main.hotel.entity.OrderInfo;
import com.main.hotel.entity.RoomType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
public interface OrderInfoRepository extends JpaRepository<OrderInfo, Integer>,
  JpaSpecificationExecutor<OrderInfo> {

  @Query(value = "select * from order_info where name= ?1", nativeQuery = true)
  OrderInfo findByOrderName(String name);
  @Modifying
  @Transactional
  @Query(value = "update order_info set order_status=3 where order_id= ?1", nativeQuery = true)
  int cancelOrder(String order_id);
  @Modifying
  @Transactional
  @Query(value = "update order_info set order_status=1 where order_id= ?1", nativeQuery = true)
  int updateOrder(String order_id);
  }
